package com.ys.utils.yinsheng.yztdock.util;

import java.io.*;
import java.util.HashMap;
import java.util.Map;


public class FileUtils {
	
	public static final Map<String,String> postfixMap=new HashMap<String,String>();
	
	/**
	 * 输入流转file
	 * @param ins
	 * @param file
	 * @throws IOException
	 * @author zhangjun
	 * @since 2019年4月1日
	 */
	public static void inputStreamToFile(InputStream ins, File file) throws IOException {
		OutputStream os = new FileOutputStream(file);
		int byteCount = 1024;
		int bytesRead = 0;
		byte[] buffer = new byte[byteCount];
		while ((bytesRead = ins.read(buffer, 0, byteCount)) != -1) {
		    os.write(buffer, 0, bytesRead);
		}
		os.close();
		ins.close();
	}
	
	/**
	 * 获取文件拓展名
	 * @param filename
	 * @return
	 * @author 杨旋
	 * @since 2018年7月17日
	 */
	public static String getExtensionName(String filename) {
        if ((filename != null) && (filename.length() > 0)) { 
            int dot = filename.lastIndexOf('.'); 
            if ((dot >-1) && (dot < (filename.length() - 1))) { 
                return filename.substring(dot + 1); 
            } 
        } 
        return filename; 
    }
	
	
	

}
